const router = require('koa-router')()
const lists = require('../model/lists')
const koaBody = require('koa-bodyparser');

router.get('/userlist', async (ctx) => {
    ctx.body = await lists.GETUSER()
    //console.log(ctx.body);
})

router.post('/deleteuser',koaBody(),async(ctx)=>{
    const ID = ctx.request.body.ID
    ctx.body = await lists.DELEUSER(ID)
    console.log(ctx.body)
})

router.post('/updateuser', koaBody(),async(ctx)=>{
    const ID = ctx.request.body.ID
    const name = ctx.request.body.username
    const password = ctx.request.body.password
    ctx.body = await lists.UPDATEUSER(ID,name,password)
    console.log(ctx.body)

})

router.post('/adduser', koaBody(),async(ctx)=>{
    const name = ctx.request.body.username
    const password = ctx.request.body.password
    ctx.body = await lists.ADDUSER(name,password)
    console.log(ctx.body)
})

module.exports = router
